package com.xuan.juc.callable;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {

        MyThread myThread = new MyThread();
        FutureTask futureTask = new FutureTask(myThread);// 适配类
        new Thread(futureTask,"A").start();
        new Thread(futureTask,"B").start(); // 结果会被缓存？
        String str = (String) futureTask.get(); // 这个get 方法可能会产生阻塞！ 把他放到最后或者异步通讯处理
        System.out.println(str);
    }
}

class MyThread implements Callable<String>{

    @Override
    public String call() throws Exception {
        return "666";
    }
}
